package com.public_module.tools;

import android.content.Context;
import android.content.pm.PackageManager;

//版本检测
public class CheckVersion {
    //版本名称
    public static String getVersionName(Context mContext) {
        String versionName = "1.0.0";
        try {
            versionName = mContext.getPackageManager().
                    getPackageInfo(mContext.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        } finally {
            return versionName;
        }
    }

    //版本号
    public static int getVersionCode(Context mContext) {
        int versionCode = 0;
        try {
            versionCode = mContext.getPackageManager().
                    getPackageInfo(mContext.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        } finally {
            return versionCode;
        }
    }
}
